package com.yiji.fintech.musfinance.common.dispatcher;

import com.google.common.eventbus.AsyncEventBus;
import com.yiji.fintech.musfinance.common.dispatcher.base.BaseLogDispatcher;
import com.yiji.fintech.musfinance.common.eventbus.event.LogEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.logging.LogLevel;
import org.springframework.stereotype.Component;

/**
 * Created by ouwen@yiji.com} on 2017/9/14.
 */
@Component
public class LogDispatcher<T> extends BaseLogDispatcher<T> {
    private AsyncEventBus eventBus;
    @Autowired
    public LogDispatcher(AsyncEventBus eventBus){
        this.eventBus = eventBus;
    }

    @Override
    protected void dispatch(T o, String m, LogLevel l) {
        LogEvent event = new LogEvent(l,m,o);
        eventBus.post(event);
    }
}
